home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hottest 6
/
Hottest 6 (1996)(PDSoft)[!].iso
/
software
/
emulators
/
tap3zxs
/
source
/
zxs3tap.c
< prev
Wrap
C/C++ Source or Header
|
1978-11-24
|
3KB
|
124 lines
/* Convert .ZXS file from stdin to .TAP file to stdout.
stderr for report/list
(C)1995 @BABOLO V.M 1.2 29.06.95
My e-mail address is: babolo@relcom.net or babolo@kiae.su
My web is: http://relcom.eu.net/zx/
Help me to collect all ZX software
*/
/* MSDOS version created 8/7/95 B.Baylis@cs.ucl.ac.uk */
/* This file was modified when I created the MSDOS version
stdin and stdout are no longer used, the .ZXS input is first parameter on
command line, and the .TAP output the second parameter.
This was done so I use could the convertors with batch files and aliases
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#define TF stderr
/*#define IF stdin*/
/*#define OF stdout*/
#define DB(h,l) ((((h)&0377)<<8)+((l)&0377))
#include "cnvout.h"
FILE * IF;
FILE * OF;
int byt, blk, nu, i;
char x;
static void pt(c)
int c;
{ c&=0377;
fputc(c,OF);
x^=c;
if(((byt++)&~0777)!=0){ blk++; byt&=0777;};
};
static int gc()
{ int c;
c=fgetc(IF);
if(c==EOF){fprintf(TF," length underflow\n"); exit(1); };
return(c&0377);
};
int main(argc, argv) int argc; char *argv[];
{ char hd[19];
int hdp, b, b0, b1;
long l;
/* modified file access */
IF=fopen(argv[1],"rb");
OF=fopen(argv[2],"wb");
for(nu=0,byt=0,blk=0
; EOF!=(b0=getc(IF))
&& EOF!=(b1=getc(IF))
&& (0!=(l=DB(b1,b0)))
;)
{ dp(nu++,3);
switch(l){
case 1: fprintf(TF," not realised\n"); exit(1);
case 2: pl1(" Wait "); goto eo;
case 3: b=gc(); pl2(" Key/%c ",b); goto eo;
case 4: b0=gc(); l=DB(b1=gc(),b0); pl2(" Wait:%-5lu ",l); goto eo;
case 5:
b=gc(); b0=gc(); b1=gc(); l=DB(b1,b0);
pl3(" Key/%c:%-5u",b,l);
eo: pl1(" "); goto ee;
default:
l-=5; pt(l); pt ((l)>>8);
p2e(l-2);
if((gc()|gc()|gc())!=0)
{ fprintf(TF," not convertable\n"); exit(1);
};
for(x=0,i=0;((hdp=i)<19)&&(i!=l);i++)pt(hd[i]=b=gc());
if((hdp>1)&&(hd[0]==0))
{ p1h(hd[1]); pl2("%c",042);
for(i=2;(i<12)&&(i<hdp);i++) pcc(hd[i]);
pl2("%c",042);
for(i=hdp;i<12;i++) bp(1);
if(hdp>=12)p2e((hdp==12)?hd[12]:DB(hd[13],hd[12]));else bp(6);
if(hdp>=14)p2e((hdp==14)?hd[14]:DB(hd[15],hd[14]));else bp(6);
if(hdp>=16)p2e((hdp==16)?hd[16]:DB(hd[17],hd[16]));else bp(6);
}
else{
p1c(hd[0]); pl1("=");
for(i=1;(i<11)&&(i<hdp);i++) pcc(hd[i]);
pl1("= ");
for(i=(hdp>0)?hdp:1;i<11;i++) bp(1);
}; };
for(i=hdp;i!=l;i++)pt(b=gc());
p1e(x); bp(1);
ee: op(blk,4); pl1("/"); op(byt,3); pl1("\n");
};
if(b0!=EOF)
{ dp(nu++,3);
if(b0!=0){ fprintf(TF," Illegal end\n"); exit(1);};
if(b1==EOF) pl1(" Zero one");
else
{ for(i=2;EOF!=(b=getc(IF));i++)b0|=b;
p2e(i);
if(b0==0)pl1(" Zeros");
else pl1(" Scrap");
};
pl1("\n");
};
exit(0);
}